<?php
namespace Admin\Controller;
use Common\Controller\CoreController;
class OrderController extends CoreController {
	public function Index(){//所有订单列表
		$this->assign('text','订单列表');
		$this->assign('orderdetails',U('Orderdetails'));
		$user=M('myorder');
		$r=$user->field("fm_myorder.*,(select username from fm_loginuser where fm_myorder.loginuser_id=fm_loginuser.id) as ordername")->select();
		// print_r($r);
		// exit;
		foreach ($r as $key => $value) {
			$aaa=M('goods_order');
			$r[$key]['goods']=$aaa->where("order_id='{$value['id']}'")->select();
		}
		// print_r($r);
		// exit;
		$this->assign('order',$r);
		$this->display();
	}

	public function Orderdetails(){//订单详情
		$this->assign('index',U('Index'));
		$this->assign('text','订单详情');
		if(!is_null(I('get.orderid'))){
			$orderid=I('get.orderid');//订单号ID
			$user=M('myorder');
			$r=$user->field("fm_myorder.*,(select username from fm_loginuser where fm_myorder.loginuser_id=fm_loginuser.id) as ordername")->where("fm_myorder.id='{$orderid}'")->select();
				foreach ($r as $key => $value) {
				$aaa=M('goods_order');
				$r[$key]['goods']=$aaa->where("order_id='$orderid'")->select();
			}
			// print_r($r);
			// exit;
			$this->assign('order',$r);
			$this->display();
		}
	}
}